import { Button } from 'antd'
import React, { useState } from 'react'
type Props = {
  children?: React.ReactNode,
  onClick?: (callback: () => void) => void
  danger?: boolean
  type?: "link" | "text" | "ghost" | "default" | "primary" | "dashed"
}

const IvButton: React.FC<Props> = (props) => {
  const { type, danger } = props
  const [isLoading, setIsLoading] = useState(false)
  function onClick() {
    setIsLoading(true)
    props.onClick(callback)
  }
  function callback() {
    setIsLoading(false)
  }
  return (
    <Button type={type} onClick={onClick} danger={danger} loading={isLoading}>
      {props.children}
    </Button>
  )
}
export default IvButton